﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Wazzup.Engine.Constants;

namespace Wazzup.Engine.Account
{
    public class WhatsAppUserManager
    {
        private Dictionary<string, WhatsAppUser> _userList;

        public WhatsAppUserManager()
        {
            this._userList = new Dictionary<string, WhatsAppUser>();
        }

        //public void AddUser(User user)
        //{
        //    //if(user == null || user.)
        //    //if(this.userList.ContainsKey())
        //}

        public WhatsAppUser CreateUser(string jid, string nickname = "")
        {
            if (this._userList.ContainsKey(jid))
                return this._userList[jid];

            string server = WhatsAppConstant.WhatsAppServer;
            if (jid.Contains("-"))
                server = WhatsAppConstant.WhatsGroupChat;

            var tmpUser = new WhatsAppUser(jid, server, nickname);
            this._userList.Add(jid, tmpUser);
            return tmpUser;
        }
    }
}
